package com.nars.networking;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.UnknownHostException;

public class HostResolver {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			InetAddress ip = InetAddress.getByName("www.google.com");
			
			
			
			//Any local address
			
			InetAddress any = InetAddress.getByName("0.0.0.0");
			System.out.println("Any: " + any.toString());
			System.out.println("Any: " + any.getLocalHost());
			
			
			//Datagram socket
			//byte[] buf = new byte[255];
			//DatagramPacket datagram = new DatagramPacket(buf, buf.length);
			
			
			
			
			
			System.out.println(ip.toString());
			System.out.println(ip.getHostName());
			System.out.println(ip.getHostAddress());
			System.out.println(ip.isAnyLocalAddress());
			System.out.println(ip.isMulticastAddress());
			try {
				System.out.println("Reachable: " + ip.isReachable(5000));
				
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
